package com.youge.rabbitmqspringboot.route;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author: hcf
 * @qq: 46914685
 * @email: 46914685@qq.com
 * @date: 2020-10-08 21:50
 */
@Component
public class RouteCustomer {

    /**
     * 第一个消费者
     * @param message
     */
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,//@Queue不设置值时,创建临时队列
                    exchange = @Exchange(value = "direct", type = "direct"),//绑定的交换机
                    key = {"info", "error", "warn"}
            )
    })
    public void recevie1(String message) {
        System.out.println("message1 = " + message);
    }

    /**
     * 第一个消费者
     * @param message
     */
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue(value = "direct_queue"),//@Queue不设置值时,创建临时队列
                    exchange = @Exchange(value = "direct", type = "direct"),//绑定的交换机
                    key = {"error"}
            )
    })
    public void recevie2(String message) {
        System.out.println("message2 = " + message);
    }
}
